﻿using System.Data.Entity.ModelConfiguration;
using DomainModel;

namespace DataAccess
{
    class ThreadConfiguration : EntityTypeConfiguration<Thread>
    {
        public ThreadConfiguration()
        {
            HasKey(p => p.Id);
            Property(p => p.Name).HasMaxLength(200).IsRequired();
            Property(p => p.Description).HasMaxLength(1000).IsRequired();
            HasRequired(p => p.Author).WithMany().WillCascadeOnDelete(false);
            HasRequired(p => p.Section).WithMany(p => p.Threads).HasForeignKey(p => p.SectionId);
        }
    }
}
